package connect4swt.gui.checkers;



import org.eclipse.swt.graphics.Point;

import com.swtdesigner.SWTResourceManager;

import connect4swt.gui.ClientWindow;
import connect4swt.gui.Piece;



/**
 * @author  Joel Cordeiro
 */
public class CheckersPiece extends Piece implements Cloneable{

	/**
	 * @author  Joel Cordeiro
	 */
	public enum ImageType {
		WHITE_EMPTY, GRAY_EMPTY, PIECE_BLUE, PIECE_ORANGE, PIECE_ORANGE_DND, CHECKER_ORANGE_DND, CHECKER_BLUE, CHECKER_ORANGE;
	}
		
	public CheckersPiece(ImageType imageType, int x, int y, int width, int height, Point position)
	{
		super(x, y, width, height, position);
		this.imageType = imageType;
		changeImage(this.imageType);		
	}	
	
	protected void changeImage(ImageType imageType) {
		switch(imageType) {
			case WHITE_EMPTY:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/CheckersPiece/grayEmptyPiece.png");
				this.imageType = ImageType.WHITE_EMPTY;
				break;
			case PIECE_BLUE:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/CheckersPiece/bluePiece.png");
				this.imageType = ImageType.PIECE_BLUE;
				break;
			case PIECE_ORANGE:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/CheckersPiece/orangePiece.png");
				this.imageType = ImageType.PIECE_ORANGE;
				break;
			case GRAY_EMPTY:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/CheckersPiece/brownEmptyPiece.png");
				this.imageType = ImageType.GRAY_EMPTY;
				break;
			case PIECE_ORANGE_DND:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/CheckersPiece/pieceDND.png");
				this.imageType = ImageType.PIECE_ORANGE_DND;
				break;
			case CHECKER_ORANGE_DND:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/CheckersPiece/checkerPieceDND.png");
				this.imageType = ImageType.CHECKER_ORANGE_DND;
				break;
			case CHECKER_BLUE:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/CheckersPiece/blueCheckersPiece.png");
				this.imageType = ImageType.CHECKER_BLUE;
				break;
			case CHECKER_ORANGE:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/CheckersPiece/orangeCheckersPiece.png");
				this.imageType = ImageType.CHECKER_ORANGE;
				break;
		}
	}
	
	public void setType(ImageType imageType) {
		this.imageType = imageType;
		changeImage(imageType);
	}
	
	@Override
	public boolean isEmpty() {
		return (this.imageType == ImageType.GRAY_EMPTY);
	}
	
	
	public boolean verifyImageType(ImageType type)
	{
		if(this.imageType == type)
			return true;		
		else return false;
	}
	
	public ImageType imageType;
	
	public Object clone(){
		Cloneable clone = new CheckersPiece(this.imageType,this.getX(),this.getY(),this.getWidth(),this.getHeight(),this.position);
		
		return clone;
	}
}
